import logging
from datetime import timedelta
from redis import StrictRedis


class Config():
    #定义同名类类属性
    DEBUG = True   #  设置调试模式
    SQLALCHEMY_DATABASE_URI = 'mysql://root:mysql@127.0.0.1:3306/info18'  # 设置数据库链接地址
    SQLALCHMY_TRACK_MODIFICATIONS = False   # 是否跟踪数据库变化
    REDIS_HOST = '127.0.0.1'
    REDIS_POST = 6379
    SESSION_TYPE = 'redis'   #session的存储机制
    SESSION_REDIS = StrictRedis(host=REDIS_HOST,port=REDIS_POST)   #  设置存储session存储对象
    SESSION_USE_SIGENR = True
    SECRET_KEY = 'sm10wP6LbxI7CFSZHpUnmHjREafUlxCT7t1XX7Xx45l2k7t5U2k+r0cg='   #  应用秘钥
    PERMANENT_SESSION_LIFETIME = timedelta(days=2)   #设置session的过期时间  默认支持过期时间
    SQLALCHEMY_COMMIT_ON_TEARDOWN = True  #设置每次请求后自动提交

#开发环境
class Developmentconfig(Config):
    DEBUG = True  # 设置调试模式
    LOG_LEVEL =logging.DEBUG
#生产环境\
class Productconfig(Config):
    DEBUG = False  # 设置调试模式
    LOG_LEVEL =logging.ERROR

config_dict = {
    "dev":Developmentconfig,

    "pro":Productconfig
}